package gui.common.detail;

import gui.ButtonName;
import gui.GuiCommon;
import gui.client.listener.ClientButtonListener;

import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

import data.Base;
import data.User;

public class UserDetail extends DetailPage{
	private static final long serialVersionUID = 1L;
	private int width=200;;
	private int height=150;

	private boolean isNew=false;
	private User user=null;
	JTextField userText=new JTextField();
	JTextField pwdText=new JTextField();

	public UserDetail(boolean isNew,Base data,boolean isServer) {
		// TODO Auto-generated constructor stub
		super(isServer);
		this.isNew=isNew;
		this.user=(User)data;
		this.setTitle("User Info");
		initDialogue();
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
	}

	private void initDialogue(){
		GuiCommon.setWindowSize(this,width,height);
		JLabel user=new JLabel("User Name:");
		JLabel password=new JLabel("Password:");

		JButton login=new JButton(ButtonName.CREATE_ACCOUNT);
		login.addActionListener(al);
		JButton cancel=new JButton(ButtonName.EXIT);
		cancel.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});
		
		

		Container contentPane = getContentPane();
		GridLayout layout=new GridLayout(3,2);
		layout.setVgap(10);
		layout.setHgap(10);
		contentPane.setLayout(layout);
		contentPane.add(user);
		contentPane.add(userText);
		contentPane.add(password);
		contentPane.add(pwdText);
		
		contentPane.add(login);
		contentPane.add(cancel);

	}

	public String getUserName() {
		// TODO Auto-generated method stub
		return userText.getText();
	}

	public String getPassword() {
		// TODO Auto-generated method stub
		return pwdText.getText();
	}

	@Override
	public Base getOperationResult() {
		return user;
	}
}
